<?php

/**
 * This is the model class for table "gn_sales_upload".
 *
 * The followings are the available columns in table 'gn_sales_upload':
 * @property string $sales_id
 * @property integer $member_id
 * @property string $member_name
 * @property string $dt_purchase
 * @property string $product_code
 * @property integer $quantity
 * @property string $bv_product_points
 * @property string $bv_earned_points
 * @property string $dt_created
 */
class SalesUpload extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return SalesUpload the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'gn_sales_upload';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('sales_id, member_id, member_name, dt_purchase, product_code, quantity, bv_product_points, bv_earned_points, dt_created', 'required'),
			array('member_id, quantity', 'numerical', 'integerOnly'=>true),
			array('sales_id', 'length', 'max'=>12),
			array('member_name', 'length', 'max'=>50),
			array('product_code', 'length', 'max'=>15),
			array('bv_product_points, bv_earned_points', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('sales_id, member_id, member_name, dt_purchase, product_code, quantity, bv_product_points, bv_earned_points, dt_created', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'sales_id' => 'Sales',
			'member_id' => 'Member',
			'member_name' => 'Member Name',
			'dt_purchase' => 'Dt Purchase',
			'product_code' => 'Product Code',
			'quantity' => 'Quantity',
			'bv_product_points' => 'Bv Product Points',
			'bv_earned_points' => 'Bv Earned Points',
			'dt_created' => 'Dt Created',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('sales_id',$this->sales_id,true);
		$criteria->compare('member_id',$this->member_id);
		$criteria->compare('member_name',$this->member_name,true);
		$criteria->compare('dt_purchase',$this->dt_purchase,true);
		$criteria->compare('product_code',$this->product_code,true);
		$criteria->compare('quantity',$this->quantity);
		$criteria->compare('bv_product_points',$this->bv_product_points,true);
		$criteria->compare('bv_earned_points',$this->bv_earned_points,true);
		$criteria->compare('dt_created',$this->dt_created,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}